package myky.com.doctorapp.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import myky.com.doctorapp.R;
import myky.com.doctorapp.entity.FollowRecordEntity;
import myky.com.doctorapp.utils.SystemUtil;


/**
 * Description:
 *
 * @author wuyang
 * Created by 2018/12/25 18:30
 */
public class FollowRecordAdapter extends BaseQuickAdapter<FollowRecordEntity.DataBean.FollowrecordlistBean, BaseViewHolder> {

    public FollowRecordAdapter(@Nullable List<FollowRecordEntity.DataBean.FollowrecordlistBean> data) {
        super(R.layout.follow_record_adapter, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FollowRecordEntity.DataBean.FollowrecordlistBean item) {

        helper.setText(R.id.record_date, SystemUtil.getStrTime_MT(item.getSendtime()));
        helper.setText(R.id.record_context, item.getTitle());

        View view = helper.getView(R.id.input_layout);
        View line = helper.getView(R.id.line_view);
        TextView preview = helper.getView(R.id.record_preview);
        ImageView state = helper.getView(R.id.follow_record_state);
        TextView btn = helper.getView(R.id.record_btn);

        /**
         * ifinput -1：最后一条数据 1：已填写 0：未填写 (-1为后台定义的参数)
         */
        if (item.getIfinput() == 1) {
            view.setVisibility(View.VISIBLE);
            preview.setVisibility(View.VISIBLE);
            line.setVisibility(View.VISIBLE);
            btn.setVisibility(View.VISIBLE);
            state.setImageResource(R.mipmap.sfjl_sj_ytx_icon);
            btn.setText("已填写");
            btn.setBackgroundResource(R.drawable.btn_gray);
            helper.setText(R.id.record_input_date, SystemUtil.getStrTime_MT(item.getInputtime()));
        } else if (item.getIfinput() == -1) {
            preview.setVisibility(View.GONE);
            view.setVisibility(View.GONE);
            btn.setVisibility(View.GONE);
            state.setImageResource(R.mipmap.sfjl_sj_ytx_icon);
        } else {
            view.setVisibility(View.GONE);
            preview.setVisibility(View.GONE);
            line.setVisibility(View.VISIBLE);
            btn.setVisibility(View.VISIBLE);
            state.setImageResource(R.mipmap.sfjl_sj_wtx_icon);
            btn.setText("开始填写");
            btn.setBackgroundResource(R.drawable.btn_green);
        }
        helper.addOnClickListener(R.id.record_btn);
        helper.addOnClickListener(R.id.record_preview);
    }
}
